<template>
  <view class="health">
    <view class="health_box">
      <view class="health_box_left">
        <view class="health_box_left_title">
          {{recordsItem.createTime.substr(5, 2)}}/{{recordsItem.createTime.substr(8, 2)}}
        </view>
        <view class="health_box_left_text" style="margin: 5rpx 0 10rpx;">{{recordsItem.createTime.substr(0, 4)}}</view>
        <view class="health_box_left_quan"></view>
        <view class="health_box_left_xian"></view>
      </view>
      <view class="health_box_right">
        <view class="health_box_right_header">
          <view class="health_box_right_header_left">
            <view class="">
              {{recordsItem.tagName}}
            </view>
            <view class="health_box_right_header_left_text">
              {{recordsItem.attributeType}}
            </view>
          </view>
          <view class="health_box_right_header_right" @click="moreOperation">
            <image src="/static/conceal.png" mode="widthFix" class="minImage"></image>
            <!--uni-app-->
            <tui-bubble-popup :show="bubbleShow" radius="30rpx" position="absolute" :mask="false" width="226rpx"
              left="-230rpx" top="70rpx" borderWidth="0" backgroundColor="#fff" color="rgba(61,61,61,1)">
              <view class="bubble_box">
                <view class="bubble_box_Item" @click="editClick">
                  <image src="/static/edit.png" mode="widthFix"></image>
                  <text>编辑</text>
                </view>
                <view class="bubble_box_Item" @click="deleteShow">
                  <image src="/static/delete.png" mode="widthFix"></image>
                  <text>删除</text>
                </view>
              </view>
            </tui-bubble-popup>
          </view>
        </view>
        <view class="health_box_right_body">
          <text>{{recordsItem.remarks}}</text>
        </view>
        <block v-if="recordsItem.sliderImgs.length == 1">
          <view class="health_box_right_img" v-for="(item,i) in recordsItem.sliderImgs" :key="i">
            <image :src="item" mode="aspectFill" class="maxImage"></image>
          </view>
        </block>
        <block v-if="recordsItem.sliderImgs.length > 1">
          <scroll-view scroll-x class="health_box_right_img">
            <view class="health_box_right_img_box" v-for="(item,i) in recordsItem.sliderImgs" :key="i">
              <image :src="item" mode="aspectFill"></image>
            </view>
          </scroll-view>
        </block>
        <view class="health_box_right_footer">
          <view class="health_box_right_footer_left">
            <image :src="recordsItem.avatar" mode="aspectFill"></image>
            <text>{{recordsItem.nickname}} 发布</text>
          </view>
          <view class="health_box_right_footer_right">
            {{recordsItem.createTime.substr(11, 5)}}
          </view>
        </view>
      </view>
    </view>

    <!--uni-app-->
    <tui-modal :show="modalShow" content="确认删除这条记录？" width="80%" :button="buttonStyle" size="40"
      color="rgba(61, 61, 61, 1)" @click="modalClick"></tui-modal>
  </view>
</template>

<script>
  import {
    removehealthPage
  } from '@/api/remind.js'
  export default {
    name: "pet_record",
    data() {
      return {
        bubbleShow: false,
        // 取消确定
        modalShow: false,
        buttonStyle: [{
            text: "取消",
            type: "white"
          },
          {
            text: "确定",
            type: "white"
          }
        ]
      };
    },
    props: {
      recordsItem: {
        type: [Object, Array],
        default: () => {
          return [];
        }
      },
    },
    methods: {
      navTo(url) {
        uni.navigateTo({
          url: url
        })
      },
      moreOperation() {
        this.bubbleShow = !this.bubbleShow
      },
      // 点击删除
      deleteShow(id) {
        this.modalShow = true
      },
      // 点击编辑
      editClick() {
        uni.redirectTo({
          url : '/subpkg/addrecordList/addrecordList?name=' + this.recordsItem.tagName + '&id=' + this.recordsItem.tagId
        })
        uni.setStorageSync('editType', this.recordsItem)
      },
      modalClick(e) {
        // console.log(e)
        if (e.index = 1) {
          removehealthPage(this.recordsItem.id).then(res => {
            // console.log(res)
            this.$util.Tips({
              title: '删除记录成功！'
            });
            this.$emit('removeType', this.recordsItem.id)
          }).catch(err => {
            this.$util.Tips({
              title: err
            });
          })
        }
        this.modalShow = false
      }
    }
  }
</script>

<style lang="scss">
  .health {
    padding: 50rpx 48rpx 0rpx 30rpx;

    .health_box {
      display: flex;
      justify-content: space-between;

      .health_box_left {
        display: flex;
        flex-direction: column;
        align-items: center;

        // justify-content: center;
        .health_box_left_title {
          color: rgba(61, 61, 61, 1);
          font-size: 30rpx;
          font-weight: bold;
        }

        .health_box_left_text {
          color: rgba(61, 61, 61, 0.5);
          font-size: 22rpx;
        }

        .health_box_left_quan {
          width: 18rpx;
          height: 18rpx;
          box-sizing: border-box;
          background-color: rgba(253, 211, 56, 1);
          border: 4rpx solid #000000;
          border-radius: 50%;
        }

        .health_box_left_xian {
          width: 1px;
          height: 100%;
          background-color: #000000;
        }
      }

      .health_box_right {
        width: 558rpx;
        height: 100%;
        background-color: rgba(255, 255, 255, 0.7);
        border-radius: 20rpx;
        padding: 34rpx 42rpx 41rpx 53rpx;
        box-sizing: border-box;

        .health_box_right_header {
          display: flex;
          justify-content: space-between;

          .health_box_right_header_left {
            display: flex;
            color: rgba(61, 61, 61, 1);
            font-size: 36rpx;

            .health_box_right_header_left_text {
              margin-left: 45rpx;
            }
          }

          .health_box_right_header_right {
            position: relative;

            .minImage {
              width: 45rpx;
            }

            .bubble_box {
              padding: 40rpx 42rpx;

              .bubble_box_Item:last-child {
                margin-bottom: 0;
              }

              .bubble_box_Item {
                display: flex;
                align-items: center;
                // justify-content: space-around;
                margin-bottom: 33rpx;

                image {
                  width: 40rpx;
                }

                text {
                  margin-left: 20rpx;
                  font-size: 30rpx;
                  color: rgba(61, 61, 61, 1);
                }
              }
            }
          }
        }

        .health_box_right_body {
          color: rgba(61, 61, 61, 1);
          font-size: 26rpx;
          line-height: 46rpx;
          margin-top: 40rpx;
        }

        .health_box_right_img {
          margin-top: 20rpx;
          white-space: nowrap;

          .maxImage {
            width: 330rpx;
            height: 330rpx;
            border-radius: 15rpx;
          }

          .health_box_right_img_box::last-child {
            margin-right: 0 !important;
          }

          .health_box_right_img_box {
            display: inline-block;
            width: 142rpx;
            height: 142rpx;
            margin-right: 18rpx;

            image {
              width: 100%;
              height: 100%;
              border-radius: 10rpx;
            }
          }
        }

        .health_box_right_footer {
          margin-top: 30rpx;
          display: flex;
          justify-content: space-between;
          align-items: center;

          .health_box_right_footer_left {
            display: flex;
            align-items: center;

            image {
              width: 40rpx;
              height: 40rpx;
              border-radius: 50%;
            }

            text {
              color: rgba(61, 61, 61, 0.8);
              font-size: 24rpx;
              margin-left: 18rpx;
            }
          }

          .health_box_right_footer_right {
            color: rgba(61, 61, 61, 0.8);
            font-size: 24rpx;
          }
        }
      }
    }
  }
</style>
